@layout("/common/_curd/_container.html"){

<script type="text/javascript">
	var ctx = "${basePath}";
	var grid_selector = "#grid-table";
	var pager_selector = "#grid-pager";
	
	$(function(){
		initGrid();
		initMenuBtn("btns", "${code}");
	});
	
	function initGrid(){
		var isadmin = "${isadmin}"
		console.log(isadmin)
		var grid_url = ctx + "/${code}/list";

		if(isadmin == "0"){
            var _colnames = ["",
                "学校",
                "时间",
                "星期",
                "餐次",
                "菜品类型",
                "菜名",
                "数量"

            ];
            var _colmodel = [{name:"id", index:"id",hidden:true, width:100},
                {name:"sname", index:"sname", width:100},
                {name:"date", index:"date", width:100},
                {name:"week", index:"week", width:100},
                {name:"time", index:"time", width:100},
                {name:"type", index:"type", width:100},
                {name:"cook", index:"cook", width:100},
                {name:"num", index:"num", hidden:true,width:100}

            ];
			jQuery(grid_selector).jqGrid({
				url : grid_url,
				shrinkToFit : true,
				colNames : _colnames,
				colModel : _colmodel,
				jsonReader : {id :"id"},
				pager : pager_selector,
				postData : {sort : "id",
					where:"{status:0}",
					order : "desc"}
			});
		}else {
            var _colnames = ["",
                "学校",
                "时间",
                "星期",
                "餐次",
                "菜品类型",
                "菜名",
                "数量",
				"状态",

            ];
            var _colmodel = [{name:"id", index:"id",hidden:true, width:100},
                {name:"sname", index:"sname", width:100},
                {name:"date", index:"date", width:100},
                {name:"week", index:"week", width:100},
                {name:"time", index:"time", width:100},
                {name:"type", index:"type", width:100},
                {name:"cook", index:"cook", width:100},
                {name:"num", index:"num", hidden:true,width:100},
                {name:"status", index:"status", width:100,formatter:function (value, row, index) {
						if(value === 0){
						    return "正常";
						}else {
						    return "<span style='color: red'>已删除</span>"
						}
                    }}
            ];
			jQuery(grid_selector).jqGrid({
				url : grid_url,
				shrinkToFit : true,
				colNames : _colnames,
				colModel : _colmodel,
				jsonReader : {id :"id"},
				pager : pager_selector,
				postData : {sort : "id", order : "desc"}
			});
		}

	}
</script>


	<!-- 配置 grid -->
	<div class="row">
		<div class="col-xs-12 tb-grid">
			<!-- 配置 查询 -->
			<!-- 按钮 -->
			<div class="welljq well-sm" id="btns"></div>
			<!-- grid -->
			<table id="grid-table"></table>
			<!-- 分页-->
			<div id="grid-pager"></div>
		</div>
	</div>
	
	<!-- 引入所需的js -->
	@include("/common/_listscript.html"){}
	
@}	